<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'form/guardable_form.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/text/form_field_text.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/select/form_field_select.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/checkbox/form_field_checkbox.class.php');
require_once(TANGRA_MAIN_DIR.'/form/static_html_form_generator.class.php');


class Sitemap_Entry_Form extends Guardable_Form {
	function __construct() {
		parent::__construct('sitemap_entry', 'admin/modules/tangra_cms/sitemap/sitemap_entry_edit.php');

		$f_path = new Form_Field_Text('path', true, 255);
		$f_path->add_potential_error('invalid_path');
		$f_path->add_potential_error('duplicate_path');
		$this->add_field($f_path);

		$f_ignore = new Form_Field_Checkbox('ignore', false);
		$this->add_field($f_ignore);

		$f_weight = new Form_Field_Select('weight', '0.5', true);
		$f_weight->add_option('0.0');
		$f_weight->add_option('0.1');
		$f_weight->add_option('0.2');
		$f_weight->add_option('0.3');
		$f_weight->add_option('0.4');
		$f_weight->add_option('0.5');
		$f_weight->add_option('0.6');
		$f_weight->add_option('0.7');
		$f_weight->add_option('0.8');
		$f_weight->add_option('0.9');
		$f_weight->add_option('1.0');
		$this->add_field($f_weight);

		$f_change_freq = new Form_Field_Select('change_freq', '4', true);
		$f_change_freq->add_option('0');
		$f_change_freq->add_option('1');
		$f_change_freq->add_option('2');
		$f_change_freq->add_option('3');
		$f_change_freq->add_option('4');
		$f_change_freq->add_option('5');
		$f_change_freq->add_option('6');
		$this->add_field($f_change_freq);
	}

	public function generate_html() {
		$html_gen = new Static_HTML_Form_Generator($this, 'modules/form_html_tpl_static_ajax_metallic_en', 'en');
		$html_gen->create_default_tpl_maps();
		$html_gen->change_field_p_error_map_entry('path', 'invalid_path', 'modules/tangra_cms/forms/en/sitemap_entry/field_error_invalid_path_en.tpl');
		$html_gen->change_field_p_error_map_entry('path', 'duplicate_path', 'modules/tangra_cms/forms/en/sitemap_entry/field_error_duplicate_path_en.tpl');

		printbr('<pre>');
		printbr(htmlentities($html_gen->get_static_html()));
		printbr('</pre>');
	}
}